#include "codekata_statistics.h"

#include <iostream>
#include <stdio.h>

#include "mockcpp/mockcpp.hpp"
#include "gtest/gtest.h"

// setuptestcase fixture
// setup everycase

extern "C" {
// for c declare of global varible
}

class StatTest : public ::testing::Test {
  protected:
    virtual void SetUp() { std::cout << "setup executor" << std::endl; }
    virtual void TearDown()
    {
        std::cout << "teardown executor" << std::endl;
        GlobalMockObject::verify();
    }
    static void SetUpTestCase() { std::cout << "setup by case" << std::endl; }
    static void TearDownTestCase()
    {
        std::cout << "teardown by case" << std::endl;
    }
};

BEST_STATUS FakeCallback(BEST_UINT32 *msgHdr, BEST_UINT32 msgLen)
{
    return BEST_OK;
}

BEST_STATUS FakeStatEchoAll(StatName name, int cnt)
{
    printf("name(%s) cnt(%d)\n", name.name, cnt);
    return BEST_OK;
}

TEST_F(StatTest, BasicTest)
{
    int ret;

    StatHandle handle;
    StatName   name = {0};
    memcpy(name.name, "basicTest", strlen("basicTest"));
    ret = StatInit(&handle, name);
    ASSERT_EQ(ret, 0);

    StatAdd(handle, 1);
    StatEchoAll(FakeStatEchoAll);

    StatAdd(handle, 1);
    StatEchoAll(FakeStatEchoAll);
}
